package com.icss;

import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.annotation.MapperScans;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

@ServletComponentScan
@SpringBootApplication
@MapperScans({
       @MapperScan("com.icss.day08.mapper"),
        @MapperScan("com.icss.day081.mapper")
})
public class SpringbootStart implements CommandLineRunner {
    public SpringbootStart() {
        System.out.println("当前类实例化");
    }
    public static void main(String[] args) {
        SpringApplication.run(SpringbootStart.class, args);
    }

    @Override
    public String toString() {
        return super.toString();
    }

    // autowired by type 根据类型 注入
    @Autowired
    ApplicationContext applicationContext;

    @Override
    public void run(String... args) throws Exception {
//
//        String[] beannames = applicationContext.getBeanDefinitionNames();
//        for (String name: beannames) {
//            // 根据名字获取 容器中bean - 获取容器中的对象
//            Object o = applicationContext.getBean(name);
//            System.out.println(name + "@@" + o);
//        }
    }
}
